package com.block.datapush.common.filter.impl;

import cn.hutool.core.util.StrUtil;
import com.block.common.service.LogFactory;
import com.block.datapush.common.enums.FilterErrorEnum;
import com.block.datapush.common.filter.IFilterHandlerService;
import com.block.datapush.common.model.param.FilterHandlerParam;
import com.block.datapush.common.model.result.FilterHandlerResult;
import com.block.db.entity.MemberExtInfo;
import org.slf4j.Logger;
import org.springframework.stereotype.Service;

@Service
public class FilterPushNumberHandlerService implements IFilterHandlerService {

    private static Logger log = LogFactory.getPushLog();


    @Override
    public FilterHandlerResult handlerFilterLogic(FilterHandlerParam handlerParam, MemberExtInfo memberExtInfo) {

        Integer pushNumber = handlerParam.getPushNumber();
        Integer successNumber = handlerParam.getSuccessNumber();

        if (pushNumber > successNumber){
            return FilterHandlerResult.success();
        }

        String message = StrUtil.format("【filter】{}【value】{}", pushNumber, successNumber);
        log.info("【机构条件判断】false【推送数量】{}", message);
        return FilterHandlerResult.error(FilterErrorEnum.CAR_ERROR, message);
    }
}
